﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace GSPatEditor.Bitmaps.DDSImpl
{
    public class MipMap
    {
        public Bitmap Bitmap
        {
            get;
            set;
        }
        public MipMap(byte[] data, int Width, int Height)
        {
            Bitmap = new Bitmap(Width, Height, PixelFormat.Format32bppArgb);

            var locked = Bitmap.LockBits(new Rectangle(0, 0, Width, Height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
            for (int i = 0; i < Height; ++i)
            {
                Marshal.Copy(data, Width * 4 * i, locked.Scan0 + locked.Stride * i, Width * 4);
            }
            Bitmap.UnlockBits(locked);
        }
        //public MipMap(BitmapSource baseimage)
        //{
        //    this.BaseImage = new WriteableBitmap(baseimage);
        //    this.BaseImage.Freeze();
        //    this.Width = this.BaseImage.PixelWidth;
        //    this.Height = this.BaseImage.PixelHeight;
        //}
    }
}
